<html><head>
   <title>Unit Testing</title>
   <meta name="generator"  content="HelpMaker.net">
   <meta name="keywords"  content="Unit Testingunittest"></head>
<body bgcolor="#FFFCEA">
<table width="100%"  border="0"  cellspacing="0"  cellpadding="2"  bgcolor="#C0C0C0">
  <tr>
    <td align="left">
      <div align="left"><font face="Arial"  color="#010101"  size="4"><span style=" font-size:14pt; font-family:Arial; color:#010101">Unit Testing</span></font></div>

    </td>
    <td align="right">
      <font face="Arial"  size="2">
        <a href="commandline.htm">Previous</a>&nbsp;<a href="pyscripter.htm">Top</a>&nbsp;<a href="editorfeatures.htm">Next</a>
      </font>
    </td>
  </tr></table>
<hr><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000">PyScripter provides important support for unit testing.&nbsp; The support comes in two levels:</span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><b>a)&nbsp; Automatic generation of test scripts</b></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000">Use the Unit Test Wizard command from the Tools menu to generate the basic structure of a test 
script.&nbsp; This command invokes the following dialog box:</span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="center"><img src="unittesting1.JPG" style="width:25.38em; height:27.25em"   border="0"  alt="graphic"></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000">The source code of the active module is scanned and its functions and methods are displayed. 
You can select (check) the functions and methods for which you want to generate tests and then 
press OK.&nbsp; A test script based on the unittest standard Python module is automatically generated 
for you.&nbsp; You can then write the code for each test that is generated.</span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><b>b)&nbsp; GUI for unit testing</b></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000">From the </span></font><a href="viewmenu.htm"><font face="Arial"  color="#0000ff"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#0000ff"><u>View Menu</u></span></font></a><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"> 
select Unit Tests to show the </span></font><a href="unittestswindow.htm"><font face="Arial"  color="#0000ff"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#0000ff"><u>Unit Tests window</u></span></font></a><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"> (see this topic for 
a detailed 
description).&nbsp; This window provides an advanced user interface for running unit tests based on 
Python's unittest standard module.</span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><i>Note:</i></span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000">To use this GUI to run tests from multiple Python files (for example tests1.py, tests2.py and 
tests3.py) create a new script with the following content:</span></font></div><div align="left"><font face="Arial"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#000000"><br></span></font></div><div align="left"><font face="Courier New"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#000000">from tests1 import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">from tests2 import *</span></font></div><div align="left"><font face="Courier New"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Courier New; color:#010101">from tests3 import *</span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101"><br></span></font></div><div align="left"><font face="Arial"  color="#010101"  size="2"><span style=" font-size:10pt; font-family:Arial; color:#010101">Then use the Unit Tests GUI with that file.</span></font></div><div align="left">&nbsp;&nbsp;</div>

</body></html>
